﻿from flask import Flask, g, render_template, request,flash,redirect,url_for,make_response
# import config
import pymysql,json,datetime
from flask_cors import CORS
app = Flask(__name__)
app.secret_key =b'\x15f\x07\xd3\xd9\xbf*\x82\xd1\xe6\xb4\xf2\x95\xdd\x8f\x12'
# app.config.from_object('config')
# cors = CORS(app, supports_credentials=True)
cors = CORS(app, resources=r'/*')

from front import *
app.register_blueprint(front_blue)
from admin import *
app.register_blueprint(login_blue)
app.register_blueprint(user_blue)
app.register_blueprint(role_blue)
app.register_blueprint(menu_blue)
app.register_blueprint(config_blue)
app.register_blueprint(log_blue)

from blog import *
app.register_blueprint(article_blue)
app.register_blueprint(category_blue)
app.register_blueprint(comment_blue)
app.register_blueprint(tags_blue)
# @app.after_request
# def cross(resp):
    # resp = make_response(resp)
    # resp.headers['Access-Control-Allow-Origin'] = '*'
    # resp.headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, OPTIONS, DELETE'
    # resp.headers['Access-Control-Allow-Credentials'] = 'True'
    # resp.headers['Connection'] = 'keep-alive'
    # resp.headers['Content-Type'] = 'application/json'
    # resp.headers['Keep-Alive'] = 'timeout=60'
    # return resp
if __name__ == '__main__':
    # import logging.handlers
    # server_log = logging.handlers.TimedRotatingFileHandler('log/server.log','D')
    # server_log.setLevel(logging.DEBUG)
    # server_log.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s'))
    # error_log = logging.handlers.TimedRotatingFileHandler('log/error.log', 'D')
    # error_log.setLevel(logging.ERROR)
    # error_log.setFormatter(logging.Formatter('%(asctime)s: %(message)s [in %(pathname)s:%(lineno)d]'))
    # app.logger.addHandler(server_log)
    # app.logger.addHandler(error_log)
    
    app.run(host='127.0.0.1', port=8080, debug=True)
	
	# bug & todo :
		# 1.登陆后刷新不了